package net.ericaro.neojavagengen;

import java.util.HashSet;
import java.util.Set;

import net.ericaro.neojavagen.classes.InterfaceTypes;
import net.ericaro.neojavagen.interfaces.ExtendsInterfaces;
import net.ericaro.neojavagen.interfaces.InterfaceBody;
import net.ericaro.neojavagen.interfaces.InterfaceMemberDeclarations;
import net.ericaro.neojavagen.interfaces.InterfaceModifier;
import net.ericaro.neojavagen.interfaces.InterfaceModifiers;
import net.ericaro.neojavagen.interfaces.NormalInterfaceDeclaration;
import net.ericaro.neojavagen.packages.TypeDeclaration;
import net.ericaro.neojavagen.types.ClassOrInterfaceType;


public class MetaInterface extends Meta{

	
	Set<MetaType> subs = new HashSet<MetaType>();
	private InterfaceMemberDeclarations interfaceMemberDeclarations;
	
	// Parsing definition
	public MetaInterface(Grammar g, String name) {
		super(g, name);
	}
	public MetaInterface withComponent(String target) {
		MetaType metaType = grammar.createMetaType(target);
		subs.add(metaType);
		
		
		
		// convert  a qualifiedIdentifiers intoa typedIdentifiers, 
		metaType.addInterfaceType(getMetaType().getClassOrInterfaceType());
		
		return this;
	}
	@Override
	protected TypeDeclaration getTypeDeclaration() {
		
		interfaceMemberDeclarations = new InterfaceMemberDeclarations();
		// maybe append some methods here
		
		// workaround, type declaration sadly handles null interfaces, but not empty ones (it generates an "implements" followed by nothing
		InterfaceTypes interfaceTypes = getMetaType().getInterfaceTypes();
		ExtendsInterfaces interfaces =null ;
		if (interfaceTypes.size() > 0 ) 
			interfaces = new ExtendsInterfaces(interfaceTypes);

		
		NormalInterfaceDeclaration normalInterfaceDeclaration = new NormalInterfaceDeclaration(null,null,new InterfaceModifiers(InterfaceModifier.PUBLIC), getMetaType().getNameIdentifier(), null, interfaces , new InterfaceBody(interfaceMemberDeclarations));
		
		return normalInterfaceDeclaration;
	}
	
	
	
	
	
	
	
	
	
	
	

}
